<?php


namespace app\api\controller;

use app\common\controller\Api;

class Order extends Api
{

    protected $noNeedLogin = [];
    protected $noNeedRight = [];


    /*
     * 订单列表
     * */
    public function index()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $user = model('Order')->orderInfo($data_array);
        $this->success('查询成功', $user);
    }

    /*
     * 订单详情
     * 
     * */
    public function details()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $user = model('Order')->details($data_array);
        $this->success('查询成功', $user);
    }

    /*
     * 生成订单
     * */
    public function createOrder()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->createOrders($data_array);
        if($res['code']){
            $this->success($res['code'],$res['data']);
        }else{
            $this->error($res['msg'],'',$res['code']);
        }
    }




    /*
   * 生成订单
   * */
    public function createVipGoodsOrders()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->createVipGoodsOrders($data_array);
        if($res['code']){
            $this->success($res['code'],$res['data']);
        }else{
            $this->error($res['msg'],'',$res['code']);
        }
    }



    /*
     * 爱心值兑换商品
     * */
    public function convert()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->converts($data_array);
        if($res['code']){
            $this->success($res['msg']);
        }else{
            $this->error($res['msg'],'',$res['code']);
        }

    }

    /*
     *  申请退款
     * */
    public function returnGoods()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->returnGoods($data_array);
        if($res['code']){
            $this->success($res['msg']);
        }else{
            $this->error($res['msg'],'',$res['code']);
        }

    }


    /*
     * 秒杀商品
     * */
    public function kill()
    {        
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->kills($data_array);
        if($res['code']){
            $this->success($res['msg'],$res['data']);
        }else{
            $this->error($res['msg']);
        }
        
    }

    /*
     * 重新提交订单
     * */
    public function upOrder()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->upOrders($data_array);
        if($res['code']){
            $this->success($res['msg'],$res['data']);
        }else{
            $this->error($res['msg']);
        }
    }


    /*
     * 确认收货
     * */
    public function receiving()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->receivings($data_array);
        if($res['code']){
            $this->success($res['msg']);
        }else{
            $this->error($res['msg']);
        }
    }

    /*
     * 物流信息
     * */
    public function logistics()
    {
        // 获取信息
        $data = $this->request->param('request_data');
        $data_json = base64_decode($data); //数据解密
        $data_array = json_decode($data_json,true);
        // 获取 user 信息
        $res = model('Order')->logistics($data_array);
        $this->success('查询成功',$res);
    }

    
}